<?php
 /*******************************************************************************
 * @filename: user.php
 *
 * @author: immer_baldos
 *
 * @description: user model
 *
 * @history:
 *
 *   VERSION   DATE                   BY          NOTES
 *  ---------------------------------------------------------------
 *     1.0     September  9, 2009     immer       initial bake
 *
 *     2.0     September 21, 2009     immer       add validateUsername()
 *
 ******************************************************************************/
class User extends AppModel {

	var $name = 'User';

    var $validate = array(
        'username' => array(
            'rule' => array('validateUsername'),
            'message' => 'Username can contain letter, numbers and \'_\' only. Length must be > 4.'
        )
        //password needs to be validated in the controller pre-sha1
    );

    function validateUsername($data){
        $value = array_values($data);
        $value = $value[0];

        if (strlen($value) < 5){
            return false;
        }

        if (preg_match("/\W/",$value)){
            return false;
        }else{
            return true;
        }
    }
}
?>